<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script>
            function myFunction() {
                var x = document.getElementById("fname");
                x.value = x.value.toUpperCase();
            }
        </script>
    </head>
    <body>
        请输入英文字符：<input type="text" id="fname" onchange="myFunction()">
        <p>当您离开输入字段时，会触发将输入文本转换为大写的函数。</p>
    </body>
</html>
